#pragma once


class RectEd : public MGUI_Widget
{
public:
	tEvent1<MGUI_Rect> evRectChanged;

public:
	RectEd(MGUI_Widget * _parent);
	~RectEd();

	void SetEditRect(const MGUI_Rect & _rect);
	const MGUI_Rect & GetEditRect();

	void SetEditClient(const MGUI_ClientRect & client);

protected:
	void _updateRect();
	void _updateClient();

protected:
	virtual void OnMouseLostFocus(MGUI_Widget* _new);
	virtual void OnMouseSetFocus(MGUI_Widget* _old);
	virtual void OnMouseDrag(int _x, int _y);
	virtual void OnMousePressed(int _x, int _y, MGUI_MouseButton _id);
	virtual void OnMouseReleased(int _x, int _y, MGUI_MouseButton _id);

	void OnLeftSetFocus_(MGUI_Widget * _old);
	void OnLeftLostFocus_(MGUI_Widget * _new);
	void OnRightSetFocus_(MGUI_Widget * _old);
	void OnRightLostFocus_(MGUI_Widget * _new);
	void OnTopSetFocus_(MGUI_Widget * _old);
	void OnTopLostFocus_(MGUI_Widget * _new);
	void OnBottomSetFocus_(MGUI_Widget * _old);
	void OnBottomLostFocus_(MGUI_Widget * _new);

	void OnLeftDrag_(int _x, int _y);
	void OnRightDrag_(int _x, int _y);
	void OnTopDrag_(int _x, int _y);
	void OnBottomDrag_(int _x, int _y);

protected:

	MGUI_Widget * mLeft;
	MGUI_Widget * mRight;
	MGUI_Widget * mTop;
	MGUI_Widget * mBottom;

	MGUI_Widget * mLeftCl;
	MGUI_Widget * mRightCl;
	MGUI_Widget * mTopCl;
	MGUI_Widget * mBottomCl;

	MGUI_Widget * mLeftLn;
	MGUI_Widget * mRightLn;
	MGUI_Widget * mTopLn;
	MGUI_Widget * mBottomLn;

	int mX, mY;
	MGUI_ClientRect mClient;

	tListener1<RectEd, MGUI_Widget *> OnLeftSetFocus;
	tListener1<RectEd, MGUI_Widget *> OnLeftLostFocus;
	tListener1<RectEd, MGUI_Widget *> OnRightSetFocus;
	tListener1<RectEd, MGUI_Widget *> OnRightLostFocus;
	tListener1<RectEd, MGUI_Widget *> OnTopSetFocus;
	tListener1<RectEd, MGUI_Widget *> OnTopLostFocus;
	tListener1<RectEd, MGUI_Widget *> OnBottomSetFocus;
	tListener1<RectEd, MGUI_Widget *> OnBottomLostFocus;

	tListener2<RectEd, int, int> OnLeftDrag;
	tListener2<RectEd, int, int> OnRightDrag;
	tListener2<RectEd, int, int> OnTopDrag;
	tListener2<RectEd, int, int> OnBottomDrag;
};

